package com.exhr.util.impl;

public class Page {
	
	private int itemCount;//总项数
	
	private int currentPage;//当前页
	
	private int currentItem;//起步项
	
	private int pageCount;//总页数
	
	private int pageSize;//每页显示数
	
	
	private boolean hasNextPage;//是否有下一页
	
	private boolean hasPrePage;//是否有上一页
	
	
	public Page(){
		this.pageSize=10;
		this.currentPage=1;
	}

	public int getItemCount() {
		return itemCount;
	}

	public void setItemCount(int itemCount) {
		this.itemCount = itemCount;
	}

	public int getCurrentPage() {
		if(currentPage>getPageCount()){
			currentPage= getPageCount();
		}
		if(currentPage<1){
			currentPage=1;
		}
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getPageCount() {
		return itemCount%pageSize==0?itemCount/pageSize:itemCount/pageSize+1;
	}


	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}


	public boolean getHasNextPage() {
		return currentPage<getPageCount();
	}


	public boolean getHasPrePage() {
		return currentPage>1;
	}

	public int getCurrentItem() {
		int flag= (currentPage-1)*pageSize;
		if(flag<0){
			return 0;
		}
		return flag;
	}
}
